package com.gxa.controller.gouhuocontroller;

import com.gxa.common.R;
import com.gxa.pojo.*;
import com.gxa.service.gouhuoservice.CangKu46Service;
import com.gxa.service.gouhuoservice.GongYingShang46Service;
import com.gxa.service.gouhuoservice.GouHuoDan46Service;
import com.gxa.service.gouhuoservice.ShangPin46Service;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.gxa.pojo.GouHuo;
import java.util.ArrayList;

/**
 * @Author x
 */
@RestController
@RequestMapping("/GouHuo")
@Api(value = "购货单" , tags = "购货数据接口API")
@RequiresPermissions("购货单")
public class GouHuoController {

    @Autowired(required = false)
    public R r;

    @Autowired(required = false)
    GongYingShang46Service gouHuoService;

    @Autowired(required = false)
    private ShangPin46Service ShangPinService;

    @Autowired(required = false)
    private CangKu46Service CangKu46Service;

    @Autowired(required = false)
    GouHuoDan46Service gouHuo1Service;


    @ApiResponses({
            @ApiResponse(code = 200, message = "请求成功"),
            @ApiResponse(code = 400, message = "参数格式不对"),
            @ApiResponse(code = 404, message = "找不到页面"),
            @ApiResponse(code = 500, message = "后台服务错误")
    })

    @RequestMapping(value = "/selectAllGongYinShangForPage", method = RequestMethod.GET)
    @ApiOperation(value = "供应商查询接口", notes = "提供当前页码数与每页显示条数", httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "当前页码数", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "size", value = "每页显示条数", required = false, dataType = "int", paramType = "query")
    })
    public R selectAllGongYinShangForPage(int page,int size) {
//        r.setCode(200);
//        r.setMsg("查询成功");
//        ArrayList<Object> list = new ArrayList<>();
//        list.add("jjj");
//        r.setData(list);
//        return r;
        return  gouHuoService.selectAllGongYingShangForPage(page,size);
    }

    @RequestMapping(value = "/selectAllGongYinShang", method = RequestMethod.GET)
    @ApiOperation(value = "供应商条件查询接口", notes = "提供当前页码数与每页显示条数", httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage", value = "当前页码数", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示条数", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "gongYingShangTypeId", value = "供应商类别", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "gongYingShangNumber", value = "供应商编号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "gongYingShangMingCheng", value = "供应商名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "lianXiRen", value = "联系人", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "phone", value = "手机", required = false, dataType = "String", paramType = "query"),
    })
    public R selectAllGongYinShang(int currentPage,int pageSize, String gongYingShangTypeld, String gongYingShangNumber,
                                   String gongYingShangMingCheng, String lianXiRen, String phone) {
//        r.setCode(200);
//        r.setMsg("success");
//        ArrayList<Object> list = new ArrayList<>();
//        GongYingShang gongYingShang = new GongYingShang();
//        gongYingShang.setGongYingShangTypeId(22);
//        gongYingShang.setGongYingShangNumber("33");
//        gongYingShang.setGongYingShangMingCheng("国信安");
//        gongYingShang.setLianXiRen("gxa");
//        gongYingShang.setPhone("shouji");
//        list.add(gongYingShang);
//        r.setData(list);
//        return r;
        return  gouHuoService.selectAllGongYinShang( currentPage , pageSize, gongYingShangTypeld, gongYingShangNumber,
                gongYingShangMingCheng , lianXiRen, phone);

    }

    @RequestMapping(value = "/selectAllShangPinForPage", method = RequestMethod.GET)
    @ApiOperation(value = "商品扫描查询接口", notes = "提供当前页码数与每页显示条数", httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage", value = "当前页码数", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pagesize", value = "每页显示条数", required = true, dataType = "int", paramType = "query")
    })
    public R selectAllShangPinForPage(int currentPage, int pageSize) {
//        r.setCode(200);
//        r.setMsg("查询成功");
//        ArrayList<Object> list = new ArrayList<>();
//        list.add("kkk");
//        r.setData(list);
//        return r;
        return  ShangPinService.selectAllShangPinForPage(currentPage, pageSize);
    }

    @RequestMapping(value = "/selectAllShangPin", method = RequestMethod.GET)
    @ApiOperation(value = "商品查询接口", notes = "提供当前页码数与每页显示条数", httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage", value = "当前页码数", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页显示条数", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "shangPinBianHao", value = "商品编号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "shangPinMingCheng", value = "商品名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "guiGeXingHao", value = "规格型号", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "unitName", value = "单位名称", required = false, dataType = "String", paramType = "query")
    })
    public R selectAllShangPin(int currentPage,int pageSize, String shangPinBianHao, String shangPinMingCheng, String guiGeXinHao,String unitName) {
//        r.setCode(200);
//        r.setMsg("success");
//        ArrayList<Object> list = new ArrayList<>();
//        ShangPin shangPin = new ShangPin();
//        shangPin.setShangPinBianHao("66");
//        shangPin.setShangPinMingCheng("68");
//        shangPin.setGuiGeXingHao("168");
//        list.add(shangPin);
//        r.setData(list);
//        return r;
        return  ShangPinService.selectAllShangPin(currentPage,pageSize,shangPinBianHao,shangPinMingCheng,guiGeXinHao,unitName);
    }

    @RequestMapping(value = "/selectbyCangKu", method = RequestMethod.GET)
    @ApiOperation(value = "仓库名称查询接口", notes = "提供当前页码数与每页显示条数", httpMethod = "get", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cangKuName", value = "显示仓库名称录入", required = true, dataType = "String", paramType = "query")
    })
    public R selectbyCangKu(String cangKuName) {
//        r.setCode(200);
//        r.setMsg("success");
//        ArrayList<Object> list = new ArrayList<>();
//        CangKu cangKu = new CangKu();
//        cangKu.setCangKuName("688");
//        list.add(cangKu);
//        r.setData(list);
//        return r;
        return  CangKu46Service.selectbyCangKu(cangKuName);
    }

    @RequestMapping(value = "/insertGouHuoDan", method = RequestMethod.POST)
    @ApiOperation(value = "保存并新增", notes = "提供当前页码数与每页显示条数", httpMethod = "post", response = R.class)
    @ApiResponses({
//            @ApiImplicitParam(name = "shuLiang", value = "数量", required = false, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "gouHuoDanJia", value = "购货单价", required = false, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "zheKouLv", value = "折扣率", required = false, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "gouHuoJinE", value = "购货金额", required = false, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "beiZhu", value = "备注", required = false, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "shangPinId", value = "商品", required = true, dataType = "int", paramType = "query"),
//            @ApiImplicitParam(name = "cangKuId", value = "仓库", required = true, dataType = "int", paramType = "query")
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })

    public R insertGouHuoDan(@RequestBody GouHuo gouHuo)
    {

        return gouHuo1Service.insertGouHuoDan(gouHuo);
    }

    @RequestMapping(value = "/ShenHeGouHuoDan", method = RequestMethod.POST)
    @ApiOperation(value = "审核购货单", notes = "提供当前页码数与每页显示条数", httpMethod = "post", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "shenHeZhuangTai", value = "审核状态", required = true, dataType = "int", paramType = "query")

    })
            public R ShenHeGouHuoDan(@RequestParam int shenHeZhuangTai) {
        return  gouHuo1Service.ShenHeGouHuoDan(shenHeZhuangTai);
    }
}
//            @ApiImplicitParam(name = "shuLiang", value = "数量", required = false, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "gouHuoDanJia", value = "购货单价", required = false, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "zheKouLv", value = "折扣率", required = false, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "zheKouE", value = "折扣额", required = false, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "gouHuoJinE", value = "购货金额", required = false, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "beiZhu", value = "备注", required = false, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "shangPin", value = "商品", required = true, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "cangKu", value = "仓库", required = true, dataType = "String", paramType = "query")

//    public R ShenHeGouHuoDan(String shuLiang,String guoHuoDanJia, String zheKouLv, String zheKouE, String gouHuoJinE,
//                               String beiZhu,@RequestParam String shangPin,@RequestParam String cangKu) {
//        r.setCode(200);
//        r.setMsg("success");
//        ArrayList<Object> list = new ArrayList<>();
//        CangKu cangKu2 = new CangKu();
//        cangKu2.setCangKuName("6888");
//        list.add(cangKu2);
//        ShangPin shangPin2 = new ShangPin();
//        shangPin2.setGuiGeXingHao("16888");
//        list.add(shangPin2);
//        r.setData(list);
//        return r;







